import React,{Component} from 'react'
import Pages from '../Pages'
import $ from 'jquery'
import {Urls} from '../../config/urls'
import * as pub from '../../config/public';
import {message} from 'antd';
class PointDetail extends Component {
	constructor(args) {
		super()
		this.state = {
			listIntegralDetails:[],
			start:'',
			totalPage:'',
			loading:false,
		}
	}
	componentWillMount(){
		var _this = this
		let _data = pub.behavior({
				username:this.props.params.id,
				start:this.state.start
			})
		$.ajax({
			type:"POST",
			url:Urls.LOOKINTEGRALDETAILS,
			data:_data,
			success:function(data){
				_this.setState({listIntegralDetails:data.listIntegralDetails?data.listIntegralDetails:[]})
				_this.setState({
					loading:false,
					totalPage:data.total
				})
			}
		})
		
	}
	jump(page){
		let _this = this
		this.setState({loading:true,start:page})
		let _data = pub.behavior({
				username:this.props.params.id,
				start:page
			})
		$.ajax({
			type:"POST",
			url:Urls.LOOKINTEGRALDETAILS,
			data:_data,
			success:function(data){
				_this.setState({listIntegralDetails:data.listIntegralDetails?data.listIntegralDetails:[]})
				_this.setState({
					loading:false,
				})
			},
			error:function(data){
				message.error('请求失败',3);
			}
		})
	}
	render(){
		return(
			<div className="container">
				<div className="common-title">会员积分详情</div>
				<div className="row">
				   <div className="integral-table bg-FFFFFF box-shadow">
				   <table>
							<thead>
								<tr>
									<th>会员名称</th>
									<th>会员等级</th>
									<th>变动时间</th>
									<th>变动类型</th>
									<th>变动详情</th>
								</tr>
							</thead>
							<tbody>
							{this.state.listIntegralDetails.map((item,index)=>{
								var sD = new Date(item.integralChangTime);
								var startTime=sD.getFullYear() + '.' + (sD.getMonth() + 1>9?sD.getMonth() + 1:'0'+(sD.getMonth() + 1)) + '.' + (sD.getDate()>9?sD.getDate():'0'+sD.getDate()) + ' ' + (sD.getHours()>9?sD.getHours():'0'+sD.getHours()) + ':' + (sD.getMinutes()>9?sD.getMinutes():'0'+sD.getMinutes()) + ':' + (sD.getSeconds()>9?sD.getSeconds():'0'+sD.getSeconds())
								return(
									<tr key={index}>
									<td>{item.userName}</td>
									<td>{item.vipGradName}</td>
									<td>{startTime}</td>
									<td>{item.integralChangType==='1'?'消费':'获得'}</td>
									<td>{item.integralChangInfo}</td>
								</tr>
									)
							})}
							</tbody>
							</table>
		           </div>
		           <div className="line"></div>
				   <Pages totalPage={this.state.totalPage} jump={this.jump.bind(this)}/>
				</div>
		   </div>

			)
	}
}
export default PointDetail;